package com.fesine.crm.service.impl;

import com.fesine.commons.enums.ResultEnum;
import com.fesine.crm.exception.CrmException;
import com.fesine.crm.po.LeaveApplyInfoPo;
import com.fesine.crm.service.LeaveApplyInfoService;
import com.fesine.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2017/10/15 21:00
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/10/15 21:00
 */
@Service
public class LeaveApplyInfoServiceImpl extends BaseServiceImpl<LeaveApplyInfoPo> implements
        LeaveApplyInfoService {


    @Override
    public int save(LeaveApplyInfoPo po) {
        Date date = new Date();
        po.setCreateTime(date);
        po.setUpdateTime(date);
        return daoService.insert(po);
    }

    @Override
    public int update(LeaveApplyInfoPo po) {
        po.setUpdateTime(new Date());
        return daoService.update(po);
    }

    @Override
    public int delete(LeaveApplyInfoPo po) {
        if (po.getStatus() == 1) {
            throw new CrmException(ResultEnum.UNAUTHORIZED);
        }
        return daoService.delete(po);
    }

}
